<?php

namespace App\Http\Controllers;

use App\Exceptions\ValidationException;
use App\Http\Controllers\BaseController;
use App\Services\VolunteerActivityService;

class VolunteerActivityController extends BaseController
{
    public function __construct(VolunteerActivityService $volunteerActivityService)
    {
        $this->volunteerActivityService = $volunteerActivityService;
    }

    public function index()
    {
         $param = $this->validationParameter([
            'page|页码' => 'noRequire|number|default:1',
            'per_page|显示数量' => 'noRequire|number|default:30',
            'keyword|搜索条件' => 'noRequire',
        ]);
        $data = $this->volunteerActivityService->getList($param);

        return $this->response->success($data);
    }

    public function show($id)
    {
        if (!$id) {
            throw new ValidationException('缺失参数');
        }

        $result = $this->volunteerActivityService->getInfo($id);

        return $this->response->success($result);
    }

}
